package com.csw.shuanfa.CodeImprove.designPattern;



/**
 * 适配器模式-对象适配器
 */
public class AdapterD1 {
    /**
     * @param args
     */
    public static void main(String[] args) {
        Rectangle rectangle = new Rectangle();
        Shape shape = new ObjectAdapter(rectangle);
        shape.draw();

    }
}

//原始接口
interface Shape {
    void draw();
}

class Rectangle implements Shape {
    @Override
    public void draw() {
        System.out.println("Rectangle deaw()");

    }
}

//适配器类
class ObjectAdapter implements Shape {
    private final Rectangle rectangle;

    public ObjectAdapter(Rectangle rectangle) {
        this.rectangle = rectangle;
    }

    @Override
    public void draw() {
        rectangle.draw();
    }
}


